# -*- coding:utf-8 -*-
from __future__ import absolute_import, unicode_literals

from datetime import timedelta

from celery import Celery, platforms
from celery.schedules import crontab
# from raven import Client
# from raven.contrib.celery import register_logger_signal, register_signal

import conf

#client = Client(conf.SENTRY_DNS)
#register_logger_signal(client)
#register_signal(client, ignore_expected=True)

platforms.C_FORCE_ROOT = True

beat = Celery(
    'beat_worker',
    broker=conf.MQ_BROKER
)


beat.conf.update(
    task_serializer='json',
    accept_content=['json'],
    result_serializer='json',
    timezone='Asia/Shanghai',
    beat_schedule={
#        'sync_flow-redis_flow_pay_check_up-every-1-min': {
#        'task': 'worker.sync_flow.redis_flow_pay_check_up',
#	'schedule': timedelta(minutes=1),
#         "options": {'queue': conf.MQ_SYNC_FLOW},
#        },
        'sync_flow-redis_flow_pay_check_up-per-mouth': {
        'task': 'worker.sync_flow.redis_flow_pay_check_up',
        'schedule': crontab(minute=0, hour=16, day_of_month=1),
        "options": {'queue': conf.MQ_SYNC_FLOW},
        },
        'monitor-ping_workers_scheduler-every-5-min': {
        'task': 'worker.monitor.ping_workers_scheduler',
        'schedule': timedelta(minutes=10),
        'options': {'queue': conf.MQ_MONITOR}
        },
        # 'elk_request_status_scheduling-xx-minnutes':{
        # 'task': 'elk_request_status_worker.elk_request_status_scheduling',
        # 'schedule': timedelta(minutes=1),
        # 'args': [1],
        # 'options': {'queue': "yunwei_elk_request_status_tasks"}
        # }
    }
)
